#ifndef _sbrush_sms_file_player_h_
#define _sbrush_sms_file_player_h_

#include "sbrush_player.h"
#include "sbrush_audio_manager.h"
#include "sbrush_spectral_model.h"
#include "dag_threading.h"
#include "sbrush_sms_synthesizer.h"

namespace sbrush {
	class SpectralModelPlayer : public Player, public AudioSource {
	public:
		SpectralModelPlayer();
		virtual ~SpectralModelPlayer() throw();
		void setModel(const SpectralModel& model);
		void start();
		void stop();
		int playHead() const;
		void seek(int pos, Whence whence);
		int length() const;
		
		
		void addAudio(float** buffer, 
					  size_t numChannels, 
					  size_t numFrames); 
	private:
		size_t addAudioInternal(float** buffer, 
								size_t numChannels,
								size_t numFrames,
								size_t bufferOffset);
		const SpectralModel* m_Model;
		size_t m_CurrentFrame;
		float* m_SynthBuffer;
		size_t m_SynthBufferSize;
		size_t m_SamplesInBuffer;
		mutable dag::Mutex m_AudioMutex;
		SmsSynthesizer m_Synthesizer;
	};
}

#endif